<template>
  <div class="bookselfAndViewed">
    <h2 class="title" v-text="title"></h2>
    <nav>
      <ul>
        <li
          :class="{ active: title === item.title }"
          @click="toPage(item.name)"
          v-for="item of nav"
          :key="item.name"
          v-text="item.title"
        ></li>
      </ul>
    </nav>
    <router-view />
  </div>
</template>

<script>
export default {
  data() {
    return {
      nav: [
        {
          id: "1",
          title: "Bookself",
          name: "bookself",
        },
        {
          id: "2",
          title: "Viewed",
          name: "viewed",
        },
      ],
    };
  },
  components: {},
  computed: {
    title() {
      return this.$route.meta.title;
    },
  },
  watch: {},
  created() {},
  mounted() {},
  methods: {
    toPage(name) {
      this.$router.push({
        name,
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.bookselfAndViewed {
  width: 1000px;
  min-height: calc(100vh - 160px);
  margin: 0 auto;
  padding: 26px 32px;
  box-sizing: border-box;
  background: #fff;
  border-radius: 16px;
  > .title {
    font-size: 24px;
    font-family: Poppins-SemiBold, Poppins;
    color: #000000;
    line-height: 40px;
  }
  nav ul {
    margin-top: 38px;
    display: flex;
    li {
      font-size: 18px;
      cursor: pointer;
      font-family: Poppins-Medium, Poppins;
      font-weight: 500;
      color: #999999;
      line-height: 29px;
      margin-right: 48px;
      &.active {
        color: #e86472;
      }
    }
  }
}
</style>
